/**
 * @author Mustafa K. Isik
 * requires compilertoys.jar
 */

import toys.base.BaseScanner;


public class MiniLangScanner extends BaseScanner {
	/*
	 * Specifies the DFA for scanning a subset of the minilang language.
	 */
	public MiniLangScanner(){
		String whitespaces = " \t" + System.getProperty("line.separator");
		String numerals = "0123456789";
		String printStatement = "print";
		
		start("start");
		
		transition("start", whitespaces, "whitespace");
		transition("whitespace", whitespaces, "whitespace");
		acceptAndIgnore("whitespace");
		
		transition("start", '+', "add");
		accept("add", true);
		
		transition("start", '-', "sub");
		accept("sub", true);
		
		transition("start", '*', "mult");
		accept("mult", true);
		
		transition("start", '/', "div");
		accept("div", true);
		
		transition("start", '%', "mod");
		accept("mod", true);
		
		transition("start", ';', "semicolon");
		accept("semicolon", true);
		
		transition("start", '(', "open");
		accept("open", true);
		
		transition("start", ')', "close");
		accept("close", true);
		
		transition("start", numerals, "num");
		transition("num", numerals, "num");
		accept("num", true);
		
		transition("start", printStatement, "print");
		accept("print", true);
	}
	
}
